<template>
    登录页
    <div>
        账号:<input type="text" v-model="account" placeholder="请输入就你的帐号">
    </div>
    <div>
        账号:<input type="password" v-model="password" placeholder="请输入就你的密码">
    </div>
    <div>
        <button>登录</button>
    </div>
    {{ account }}
    {{ password }}
</template>

<script setup>
import {ref} from 'vue'
import {userRouter} from 'vue-router'
import {useStore} from 'vuex'

const account = ref('')
const password = ref ('')


//拿到路由的实例化对象
const router = userRouter()
//拿到Vuex的实例化对象
const store = userStore()

const submit = ()=>{
    console.log('222');
    if(account.value === 'admin' && password.value === '123456'){
        alert("登陆成功")

        //保存用户信息
        store.commit("updateUserInfo",{
            name:'张三',
            gender:'男',
            phone:'13455556666'

            //跳转到用户中心
            router.push({path:'/user'})
        }) 
    } else{
        alert("账号或密码错误，请重新输入")
    }
}
</script>